package cn.calm.server.action;

import java.util.ArrayList;
import java.util.List;

import cn.calm.commons.entity.Content;

import com.opensymphony.xwork2.ActionSupport;

public class JsonAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private List<Content> contents = new ArrayList<Content>();

	public JsonAction() {
		try {
			initData();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

	public String listAll() {

		return "listAll";
	}

	private void initData() throws InterruptedException {
		Content con;
		for (int i = 0; i < 100; i++) {
			con = new Content();
			Thread.sleep(10);
			con.setDescription("description" + i);
			con.setId(i);
			con.setName("name" + i);
			con.setUrl("/server/img/" + i % 4 + ".jpg");
			contents.add(con);
		}
	}

	public List<Content> getContents() {
		return contents;
	}

	public void setContents(List<Content> contents) {
		this.contents = contents;
	}

}
